import { IPSDataEntity } from '../ipsdata-entity';
import { IPSDEDataSync } from '../datasync/ipsdedata-sync';
import { IPSDEDEDataSyncLogic } from './ipsdededata-sync-logic';
import { IPSDELogic } from './ipsdelogic';
import { IPSDELogicParam } from './ipsdelogic-param';
import { PSDELogicNodeImpl } from './psdelogic-node-impl';

export class PSDEDEDataSyncLogicImpl extends PSDELogicNodeImpl implements IPSDEDEDataSyncLogic {
  protected dstpsdedatasync: IPSDEDataSync | null = null;

  getDstPSDEDataSync(): IPSDEDataSync | null {
    if (this.dstpsdedatasync != null) return this.dstpsdedatasync;
    const value = this.M.getDstPSDEDataSync;
    if (value == null) {
      return null;
    }
    this.dstpsdedatasync = this.getDstPSDataEntityMust().findPSDEDataSync(value);
    return this.dstpsdedatasync;
  }

  get dstPSDEDataSync(): IPSDEDataSync | null {
    return this.getDstPSDEDataSync();
  }

  getDstPSDEDataSyncMust(): IPSDEDataSync {
    const value = this.getDstPSDEDataSync();
    if (value == null) {
      throw new Error('未指定目标实体数据同步对象');
    }
    return value;
  }

  protected dstpsdelogicparam: IPSDELogicParam | null = null;

  getDstPSDELogicParam(): IPSDELogicParam | null {
    if (this.dstpsdelogicparam != null) return this.dstpsdelogicparam;
    const value = this.M.getDstPSDELogicParam;
    if (value == null) {
      return null;
    }
    const ipsdelogic = this.getParentPSModelObject('dataentity.logic.IPSDELogic') as IPSDELogic;
    if (ipsdelogic != null) {
      this.dstpsdelogicparam = ipsdelogic.findPSDELogicParam(value);
    }
    return this.dstpsdelogicparam;
  }

  get dstPSDELogicParam(): IPSDELogicParam | null {
    return this.getDstPSDELogicParam();
  }

  getDstPSDELogicParamMust(): IPSDELogicParam {
    const value = this.getDstPSDELogicParam();
    if (value == null) {
      throw new Error('未指定目标逻辑参数对象');
    }
    return value;
  }

  protected dstpsdataentity: IPSDataEntity | null = null;

  getDstPSDataEntity(): IPSDataEntity | null {
    if (this.dstpsdataentity != null) return this.dstpsdataentity;
    const value = this.M.getDstPSDataEntity;
    if (value == null) {
      return null;
    }
    this.dstpsdataentity = this.getPSModel4('dataentity.IPSDataEntity', value, 'getDstPSDataEntity') as IPSDataEntity;
    return this.dstpsdataentity;
  }

  get dstPSDataEntity(): IPSDataEntity | null {
    return this.getDstPSDataEntity();
  }

  getDstPSDataEntityMust(): IPSDataEntity {
    const value = this.getDstPSDataEntity();
    if (value == null) {
      throw new Error('未指定目标实体对象');
    }
    return value;
  }

  get eventType(): 1 | 2 | 4 | 256 | 512 {
    return this.M.eventType != null ? this.M.eventType : 0;
  }

  get cls(): string {
    return 'PSDEDEDataSyncLogicImpl';
  }

  instanceof(cls: string): boolean {
    if (cls == 'dataentity.logic.IPSDEDEDataSyncLogic') return true;
    return super.instanceof(cls);
  }
}
